//
//  BRLoginTipsView.m
//  BrezzeSaaS
//
//  Created by IOS on 2021/9/23.
//  Copyright © 2021 Brezze GWG. All rights reserved.
//

#import "BRLoginTipsView.h"
@interface BRLoginTipsView ()
{
    QMUILabel *_decLB;
}

@end

@implementation BRLoginTipsView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self setUI];
    }
    return self;
}


- (void)show:(BRLOGIN_STAUS)status {
    NSString *str = status == BRLogin_phone ? Localized(@"Login_tipsPhone") : Localized(@"Login_tipsEmail");
    _decLB.text = str;
    [_decLB sizeToFit];
    self.hidden = NO;
}

- (void)hidd {
    self.hidden = YES;
    
}

- (void)iGetIt {
    
    [self hidd];
    
    if (self.getCodeClick) {
        self.getCodeClick();
    }
}

- (void)setUI {
    self.backgroundColor = UIColorShadow;
    [self hidd];
    UIView *contentView = [[UIView  alloc] init];
    contentView.backgroundColor = UIColorWhite;
    contentView.layer.cornerRadius = 13.;
    [self addSubview:contentView];
    [contentView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(350);
        make.centerX.equalTo(self);
        make.centerY.equalTo(self);
        make.left.equalTo(self).offset(28);
        make.right.equalTo(self).offset(-28);
    }];
    
    UIImageView *imgV = [[UIImageView alloc] init];
    imgV.image = UIImageMake(@"login_img");
    [contentView addSubview:imgV];
    [imgV mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(210);
        make.centerX.equalTo(contentView);
        make.width.mas_equalTo(280);
        make.top.equalTo(contentView).offset(0);
    }];
    
    UIView *line = [BRToolsView getLineView];
    line.backgroundColor = UIColorMakeWithRGBA(0, 0, 0, 0.1);
    [contentView addSubview:line];
    [line mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.mas_equalTo(0.5);
        make.centerX.equalTo(contentView);
        make.left.equalTo(contentView).offset(28);
        make.bottom.equalTo(contentView.mas_bottom).offset(-51);
    }];
    
    
    QMUIButton *getBtn = [[QMUIButton alloc] init];
    [getBtn setTitle:Localized(@"Login_tipsGetit") forState:UIControlStateNormal];
    [getBtn setTitleColor:kColorMain forState:UIControlStateNormal];
    getBtn.titleLabel.font = [UIFont br_fontS:15];
    getBtn.tag = 101;
    [contentView addSubview:getBtn];
    [getBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.width.mas_equalTo(contentView);
        make.height.mas_equalTo(50);
        make.bottom.equalTo(contentView).offset(0);
        make.left.equalTo(contentView.mas_left).offset(0);
    }];
    
    [getBtn addTarget:self action:@selector(iGetIt) forControlEvents:UIControlEventTouchUpInside];
    
    QMUILabel *titleLabel = [[QMUILabel alloc] init];
    titleLabel.font = [UIFont br_fontS:14];
    titleLabel.numberOfLines = 0;
    titleLabel.textAlignment = NSTextAlignmentCenter;
    titleLabel.textColor = UIColorText1;
    titleLabel.text = Localized(@"Login_tipsPhone");
    [contentView addSubview:titleLabel];
    [titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(imgV.mas_bottom).offset(24);
        make.centerX.equalTo(contentView);
        make.left.equalTo(contentView).offset(28);
    }];
    _decLB = titleLabel;
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
